package com.hexb.test


import com.hexb.core.utils.DESUtils
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

/**
 * @Package : com.hexb.test
 * @Author : hexb 
 * @Date : 2018-08-17 11:35
 */
@RunWith(JUnit4.class)
class DESTest {


    @Test
    void testReflectionUtils() {
        String key = 'Zay0d1cHjEOa0fmc'
        //println DESUtils.decrypt('kqu9rFas00eOBv/6lVTDx2DXqlPESCoQ',key)
        //println DESUtils.decrypt('kqu9rFas00eOBv/6lVTDx2DXqlPESCoQ','XUlSc38md5I1LHtW')
        //println DESUtils.encrypt(UUID.randomUUID().toString(),key)

        println DESUtils.encrypt(UUID.randomUUID().toString(),'feitian-xop')

        int machineId = 1;//最大支持1-9个集群机器部署
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if(hashCodeV < 0) {//有可能是负数
            hashCodeV = - hashCodeV;
        }
        println machineId + String.format("%015d", hashCodeV);
    }

//    @Test
    void testEncryptAndDecrypt(){
        String key = 'Zay0d1cHjEOa0fmc'
        String str = '431230198905046924'

        String ened = DESUtils.encrypt(str,key)
        String ened2 = DESUtils.encrypt(str,key)
        String deed = DESUtils.decrypt(ened,key)

        println "加密后:${ened}"
        println "加密后:${ened2}"
        println deed
    }


}
